package com.songlanyun.modules.logisticscompany.controller.api;

import com.alibaba.fastjson.JSONArray;
import com.songlanyun.common.utils.R;
import com.songlanyun.common.utils.logistics.LogisticsUtil;
import com.songlanyun.modules.logisticscompany.entity.SystemLogisticsCompanyEntity;
import com.songlanyun.modules.logisticscompany.service.SystemLogisticsCompanyService;
import com.songlanyun.modules.user.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * 平台发布的可适用的物流公司表
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2020-11-12 11:05:31
 */
@RestController
@RequestMapping("api/logistics/company")
public class SystemLogisticsCompanyApiController extends AbstractController {
    @Autowired
    private SystemLogisticsCompanyService systemLogisticsCompanyService;

    @Resource
    private LogisticsUtil logisticsUtil;

    /**
     * 列表
     */
    @GetMapping("/select")
    public R list() {
        List<SystemLogisticsCompanyEntity> list = systemLogisticsCompanyService.list();

        return R.ok().put("list", list);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id) {
        SystemLogisticsCompanyEntity systemlogisticscompany = systemLogisticsCompanyService.getById(id);

        return R.ok().put("data", systemlogisticscompany);
    }

    /**
     * 获取所有的物流公司
     */
    @GetMapping("/all")
    public R all() {
        return R.ok().put("data", logisticsUtil.get());
    }
}
